Functions in Explain™ are very similar to functions in C or Pascal. As in most modern functional languages, each function has a name, an argument list, and a list of statements to be executed in sequence. Explain, like common procedural languages, uses functions to manage execution flow.
function SwapPrint(A, B)
if (A lt B)
;Exchange A & B
Temp = A
A = B
B = Temp
Count = Show(A, B)
return
function Show(V1, V2)
Printl("1st Value = ",V1)
Printl("2nd Value = ",V2)
V1+V2 ; last evaluated value is returned
return
Note the following Explain features:
Program statements are generally one line long, but they can be continued over several lines. When statements are continued, they must have the same indentation level as the first line of the statement. For example, Function1 below has three parameters:
Function1("Parameter1 is very long title string which may not be shown completely if you do not scroll to the right and look at it.",param2, param3)
This can make the code difficult to read. You can force the compiler to disregard indentation changes by putting an ampersand "&" as the first character on a line, for example:
Function1("Parameter1 is still a very long title string but will be shown
& completely because we used a continue symbol.", param2, param3)
As you can see, the second code-segment is easier to understand.